<?php

/**
 * ClassName:用户房间操作表
 * @auditor LeiJunXiang
 * @time 2024/12/05
 */

namespace app\modelOpreate\onlineChat;

use app\modelOpreate\ModelOpeBase;
use think\facade\Db;

class UserRoomOpe extends ModelOpeBase
{
    const TOOL_USER_ROOM_OPE = "UserRoomOpe";

    /**
     * 获取该用户所有房间号，用户头像，名称(用户id)
     */
    public function getAllRoomNumberByUserId($userId)
    {
        $roomNumbers = Db::table($this->table)
            ->alias('ur') // 为主表设置别名
            ->join('ForumUser u', 'ur.recipientUserId = u.userId') // 连接user表，
            ->where("ur.userId", $userId)
            ->field("ur.roomNumber,u.userName,u.userIcon,u.userId")
            ->select();
        return $roomNumbers;
    }

}